package com.weiyi.mashangzhu.Roomer.Adapter;


import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.weiyi.mashangzhu.Base.BaseListAdapter;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.FacilityInfo;

import java.util.List;

public class FacilityAdapter extends BaseListAdapter<FacilityInfo> {

    public FacilityAdapter(Context context, List<FacilityInfo> list) {
        super(context, list);
    }

    @Override
    public View initView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_house_detail_facility_grid, null);
            holder = new ViewHolder();
            holder.facility = (TextView) convertView.findViewById(R.id.house_facility);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        FacilityInfo facility = mList.get(position);
        holder.facility.setText(facility.getTitle());
        Drawable drawable = mContext.getResources().getDrawable(facility.getIcon_yes());
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        holder.facility.setCompoundDrawables(null, drawable, null, null);

        return convertView;
    }

    private class ViewHolder {
        private TextView facility;
    }
}
